import React from 'react';
import { Row, Col, Table} from 'antd';
import './style.scss';
import { valueToDataType,
    valueToTF,
    valueToShareMode,
    valueToResStatus,
    valueToShareType,
    valueToResourceForm,
    valueToResourceFormType,
    valueToShareModeType,
    valueToUpdateCycle,
    valueToisOpen} from './commonConfig'
const { Column} = Table
const CommonView =({dataSource, infos, ...props}) => {
    const { resourceName, resourceId, resourceAbbName, catalogueNumber, resourceForm, resourceFormType,
        shareType, shareCondition, shareMode, shareModeType, isOpen, openCondition, updateCycle,
        description, resourceProvider, wholeName,} = infos
    return (
        <div className='view'>
                <p style={{fontSize:15,fontWeight:'bold'}}>基本信息</p>
                <Row>
                    <Col span={12}>
                        <p><span className='left'>资源分类</span><span style={{marginLeft:20}}>{wholeName}</span></p>
                        <p><span className='left'>资源名称</span><span style={{marginLeft:20}}>{resourceName}</span></p>
                        <p><span className='left'>共享类型</span><span style={{marginLeft:20}}>{valueToShareType[shareType]}</span></p>
                        <p><span className='left'>共享方式</span><span style={{marginLeft:20}}>{valueToShareMode[shareMode]}</span></p>
                        <p><span className='left'>资源格式</span><span style={{marginLeft:20}}>{valueToResourceForm[resourceForm]}</span></p>
                        <p><span className='left'>是否向社会开放</span><span style={{marginLeft:20}}>{valueToisOpen[isOpen]}</span></p>
                        <p><span className='left'>更新周期</span><span style={{marginLeft:20}}>{valueToUpdateCycle[updateCycle]}</span></p>
                    </Col>
                    <Col span={12}>
                        <p><span className='left'>资源代码</span><span style={{marginLeft:20}}>{resourceId}</span></p>
                        <p><span className='left'>资源简称</span><span style={{marginLeft:20}}>{resourceAbbName}</span></p>
                        <p><span className='left'>共享条件</span><span style={{marginLeft:20}}>{shareCondition}</span></p>
                        <p><span className='left'>共享方式类型</span><span style={{marginLeft:20}}>{valueToShareModeType[shareModeType]}</span></p>
                        <p><span className='left'>资源格式类型</span><span style={{marginLeft:20}}>{valueToResourceFormType[resourceFormType]}</span></p>
                        <p><span className='left'>开放条件</span><span style={{marginLeft:20}}>{openCondition}</span></p>
                        <p><span className='left'>摘要</span><span style={{marginLeft:20}}>{description}</span></p>
                    </Col>
                </Row>
                <Row className='secondRow'>
                    <Col span={12}>
                        <p><span className='left'>资源提供方</span><span style={{marginLeft:20}}>{resourceProvider}</span></p>
                        <p><span className='left'>提供方联系人</span><span style={{marginLeft:20}}>2017市民户口信息</span></p>
                    </Col>
                    <Col span={12}>
                        <p><span className='left'>提供方代码</span><span style={{marginLeft:20}}>{catalogueNumber}</span></p>
                        <p><span className='left'>联系人电话</span><span style={{marginLeft:20}}>户口信息</span></p>
                    </Col>
                </Row>
                <Row>
                    <Col span={24}>
                        <p style={{fontSize:15,fontWeight:'bold',height:30}}>数据项信息</p>
                        <Table dataSource={dataSource} size="small" rowKey={record => record.dataId}>
                            <Column title="序号" render={(text, record, index)=><span>{index+1}</span>} />
                            <Column title="英文名" dataIndex="name" key="name"/>
                            <Column title="中文名" dataIndex="cnName" key="cnName"/>
                            <Column title="数据类型" dataIndex="datatype" key="datatype" render={(text,record)=>{return <span >{valueToDataType[text]}</span>}} />
                            <Column title="是否主键" dataIndex="isPk" key="isPk" render={(text,record)=>{return <span >{valueToTF[text]}</span>}} />
                            <Column title="是否增量" dataIndex="increment" key="increment" render={(text,record)=>{return <span >{valueToTF[text]}</span>}} />
                            <Column title="是否为空" dataIndex="isNull" key="isNull" render={(text,record)=>{return <span >{valueToTF[text]}</span>}} />
                        </Table>
                    </Col>
                </Row>
            </div>
    )
}

export default CommonView;